package com.rq.rvlibrary;

import android.widget.TextView;

/**
 * @author RQ
 * date    2021-11-04 10:34
 * 此文件用于BaseViewHolder 最后的数据填充辅助
 */
public class BVH {
    private static BVHHelper helper;

    public interface BVHHelper {

        boolean modifyText();

        void setText(CharSequence text, TextView tv);

        boolean modifyColor();

        void setColor2View(int colorId, TextView tv);
    }

    public static void setHelper(BVHHelper helper) {
        BVH.helper = helper;
    }

    public static void setColor2View(int colorId, TextView tv) {
        if (helper != null && helper.modifyColor()) {
            helper.setColor2View(colorId, tv);
            return;
        }
        try {
            tv.setTextColor(tv.getResources().getColor(colorId));
        } catch (Exception e) {
            tv.setTextColor(colorId);
        }
    }

    public static void setChar2View(CharSequence text, TextView tv) {
        if (helper != null && helper.modifyText()) {
            helper.setText(text, tv);
            return;
        }
        tv.setText(text);
    }
}
